<?php 
      echo $this->Html->css("validationEngine.jquery");
      echo $this->Html->css("uploadify");
 ?>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/customInput.jquery.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/manager_promotions.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/zice.custom1.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/chosen.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/jquery.validationEngine.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/jquery.validationEngine-vi.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/uploadify/jquery.uploadify.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>js/jquery.autotab.js"></script>
<script type="text/javascript" >
$(function() {
	$("#fileupload1").uploadify({
			'fileTypeDesc' : 'Image Files',
	        'fileTypeExts' : '*.jpg', 
			'swf'      : '<?php echo $this->webroot; ?>js/uploadify/uploadify.swf',
			'uploader' : '<?php echo $this->webroot; ?>js/uploadify/uploadify.php',
			'onUploadSuccess' : function(file, data, response) {
				if(data == 1){
					$('#resultUpload1').html("<p>Upload hình thành công</p><img src='<?php echo $this->webroot; ?>img/news/" + file.name +"'/><input id='filenameUpload1' type='hidden' value='"+file.name+"'/>");
				}
				else{
					$('#resultUpload1').html("<p>Định dạng hình không đúng.</p>");
				}
	        } 
		});
	$("#fileupload2").uploadify({
		'fileTypeDesc' : 'Image Files',
        'fileTypeExts' : '*.jpg', 
		'swf'      : '<?php echo $this->webroot; ?>js/uploadify/uploadify.swf',
		'uploader' : '<?php echo $this->webroot; ?>js/uploadify/uploadify.php',
		'onUploadSuccess' : function(file, data, response) {
			if(data == 1){
				$('#resultUpload2').html("<p>Upload hình thành công</p><img src='<?php echo $this->webroot; ?>img/news/" + file.name +"'/><input id='filenameUpload2' type='hidden' value='"+file.name+"'/>");
			}
			else{
				$('#resultUpload2').html("<p>Định dạng hình không đúng.</p>");
			}
        } 
	});
	$("#fileupload3").uploadify({
		'fileTypeDesc' : 'Image Files',
        'fileTypeExts' : '*.jpg', 
		'swf'      : '<?php echo $this->webroot; ?>js/uploadify/uploadify.swf',
		'uploader' : '<?php echo $this->webroot; ?>js/uploadify/uploadify.php',
		'onUploadSuccess' : function(file, data, response) {
			if(data == 1){
				$('#resultUpload3').html("<p>Upload hình thành công</p><img src='<?php echo $this->webroot; ?>img/news/" + file.name +"'/><input id='filenameUpload3' type='hidden' value='"+file.name+"'/>");
			}
			else{
				$('#resultUpload3').html("<p>Định dạng hình không đúng.</p>");
			}
        } 
	});
	$("#fileupload4").uploadify({
		'fileTypeDesc' : 'Image Files',
        'fileTypeExts' : '*.jpg', 
		'swf'      : '<?php echo $this->webroot; ?>js/uploadify/uploadify.swf',
		'uploader' : '<?php echo $this->webroot; ?>js/uploadify/uploadify.php',
		'onUploadSuccess' : function(file, data, response) {
			if(data == 1){
				$('#resultUpload4').html("<p>Upload hình thành công</p><img src='<?php echo $this->webroot; ?>img/news/" + file.name +"'/><input id='filenameUpload4' type='hidden' value='"+file.name+"'/>");
			}
			else{
				$('#resultUpload4').html("<p>Định dạng hình không đúng.</p>");
			}
        } 
	});
	$("#fileupload5").uploadify({
		'fileTypeDesc' : 'Image Files',
        'fileTypeExts' : '*.jpg', 
		'swf'      : '<?php echo $this->webroot; ?>js/uploadify/uploadify.swf',
		'uploader' : '<?php echo $this->webroot; ?>js/uploadify/uploadify.php',
		'onUploadSuccess' : function(file, data, response) {
			if(data == 1){
				$('#resultUpload5').html("<p>Upload hình thành công</p><img src='<?php echo $this->webroot; ?>img/news/" + file.name +"'/><input id='filenameUpload5' type='hidden' value='"+file.name+"'/>");
			}
			else{
				$('#resultUpload5').html("<p>Định dạng hình không đúng.</p>");
			}
        } 
	});
});
</script>
<div class="titlePage">
<h1>Quản lý quảng cáo</h1>
</div>
<div class="onecolumn">
	<div class="header">
		<span><span class="ico gray shopping_basket"></span>Quảng cáo chính</span>
	</div>
	<div class=" clear"></div>
	<div class="content">
		<form id="validation">
			<div class="newPromotion1">
				<h4>Quảng cáo</h4>
				<?php foreach ($promotion1 as $item) {?>
				<div class="section">
					<label>
					Tên quảng cáo:				
					</label>
					<div>
						<input class="validate[required] large" type="text" id="promotion_name1" value="<?php echo $item['p']['name']; ?>">					
					</div>
				</div>
				<div class="section">
					<label>
					Link quảng cáo:
					
					</label>
					<div>
						<input class="validate[required,custom[url]] large" type="text" id="promotion_link1" value="<?php echo $item['p']['link']; ?>">
					</div>
				</div>
				<div class="section">
					<label>
					Hình ảnh:
					
					</label>
					<div>
						<input type="file" class="fileupload" id="fileupload1"/>
                    </div>
                    <div id="resultUpload1">
                    	<img src="<?php echo $this->webroot; ?>img/news/<?php echo $item['p']['image'];?>"/><input id='filenameUpload1' type='hidden' value="<?php echo $item['p']['image'];}?>"/>
                    </div>
				</div>
				<div class="buttonNewPromotion">
					<a class="uibutton add_promotion" id="1"><span class="ico gray checkmark2"></span>Lưu</a>
					<a class="uibutton special cancel"><span class="ico gray cross"></span>Hủy</a>
				</div>
			</div>
		</form>
	</div>
</div>

<div class="onecolumn">
	<div class="header">
		<span><span class="ico gray shopping_basket"></span>Quảng cáo phụ</span>
	</div>
	<div class=" clear"></div>
	<div class="content">
		<form id="validation">
			<div class="newPromotion2">
				<h4>Quảng cáo trái</h4>
				<?php foreach ($promotion2 as $item) {?>
				<div class="section">
					<label>
					Tên quảng cáo:				
					</label>
					<div>
						<input class="validate[required] large" type="text" id="promotion_name2" value="<?php echo $item['p']['name']; ?>">					
					</div>
				</div>
				<div class="section">
					<label>
					Link quảng cáo:
					
					</label>
					<div>
						<input class="validate[required,custom[url]] large" type="text" id="promotion_link2" value="<?php echo $item['p']['link']; ?>">
					</div>
				</div>
				<div class="section">
					<label>
					Hình ảnh:
					
					</label>
					<div>
						<input type="file" class="fileupload" id="fileupload2"/>
                    </div>
                    <div id="resultUpload2">
                    	<img src="<?php echo $this->webroot; ?>img/news/<?php echo $item['p']['image'];?>"/><input id='filenameUpload2' type='hidden' value="<?php echo $item['p']['image'];}?>"/>
                    </div>
				</div>
				<div class="buttonNewPromotion">
					<a class="uibutton add_promotion" id="2"><span class="ico gray checkmark2"></span>Lưu</a>
					<a class="uibutton special cancel"><span class="ico gray cross"></span>Hủy</a>
				</div>
			</div>
			
			<div class="newPromotion3">
				<h4>Quảng cáo phải</h4>
				<?php foreach ($promotion3 as $item) {?>
				<div class="section">
					<label>
					Tên quảng cáo:				
					</label>
					<div>
						<input class="validate[required] large" type="text" id="promotion_name3" value="<?php echo $item['p']['name']; ?>">					
					</div>
				</div>
				<div class="section">
					<label>
					Link quảng cáo:
					
					</label>
					<div>
						<input class="validate[required,custom[url]] large" type="text" id="promotion_link3" value="<?php echo $item['p']['link']; ?>">
					</div>
				</div>
				<div class="section">
					<label>
					Hình ảnh:
					
					</label>
					<div>
						<input type="file" class="fileupload" id="fileupload3"/>
                    </div>
                    <div id="resultUpload3">
                    	<img src="<?php echo $this->webroot; ?>img/news/<?php echo $item['p']['image'];?>"/><input id='filenameUpload3' type='hidden' value="<?php echo $item['p']['image'];}?>"/>
                    </div>
				</div>
				<div class="buttonNewPromotion">
					<a class="uibutton add_promotion" id="3"><span class="ico gray checkmark2"></span>Lưu</a>
					<a class="uibutton special cancel"><span class="ico gray cross"></span>Hủy</a>
				</div>
			</div>
		</form>
	</div>
</div>

<div class="onecolumn">
	<div class="header">
		<span><span class="ico gray shopping_basket"></span>Quảng cáo trượt</span>
	</div>
	<div class=" clear"></div>
	<div class="content">
		<form id="validation">
			<div class="newPromotion4">
				<h4>Quảng cáo trái</h4>
				<?php foreach ($promotion4 as $item) {?>
				<div class="section">
					<label>
					Tên quảng cáo:				
					</label>
					<div>
						<input class="validate[required] large" type="text" id="promotion_name4" value="<?php echo $item['p']['name']; ?>">					
					</div>
				</div>
				<div class="section">
					<label>
					Link quảng cáo:
					
					</label>
					<div>
						<input class="validate[required,custom[url]] large" type="text" id="promotion_link4" value="<?php echo $item['p']['link']; ?>">
					</div>
				</div>
				<div class="section">
					<label>
					Hình ảnh:
					
					</label>
					<div>
						<input type="file" class="fileupload" id="fileupload4"/>
                    </div>
                    <div id="resultUpload4">
                    	<img src="<?php echo $this->webroot; ?>img/news/<?php echo $item['p']['image'];?>"/><input id='filenameUpload4' type='hidden' value="<?php echo $item['p']['image'];}?>"/>
                    </div>
				</div>
				<div class="buttonNewPromotion">
					<a class="uibutton add_promotion" id="4"><span class="ico gray checkmark2"></span>Lưu</a>
					<a class="uibutton special cancel"><span class="ico gray cross"></span>Hủy</a>
				</div>
			</div>
			
			<div class="newPromotion5">
				<h4>Quảng cáo phải</h4>
				<?php foreach ($promotion5 as $item) {?>
				<div class="section">
					<label>
					Tên quảng cáo:				
					</label>
					<div>
						<input class="validate[required] large" type="text" id="promotion_name5" value="<?php echo $item['p']['name']; ?>">					
					</div>
				</div>
				<div class="section">
					<label>
					Link quảng cáo:
					
					</label>
					<div>
						<input class="validate[required,custom[url]] large" type="text" id="promotion_link5" value="<?php echo $item['p']['link']; ?>">
					</div>
				</div>
				<div class="section">
					<label>
					Hình ảnh:
					
					</label>
					<div>
						<input type="file" class="fileupload" id="fileupload5"/>
                    </div>
                    <div id="resultUpload5">
                    	<img src="<?php echo $this->webroot; ?>img/news/<?php echo $item['p']['image'];?>"/><input id='filenameUpload5' type='hidden' value="<?php echo $item['p']['image'];}?>"/>
                    </div>
				</div>
				<div class="buttonNewPromotion">
					<a class="uibutton add_promotion" id="5"><span class="ico gray checkmark2"></span>Lưu</a>
					<a class="uibutton special cancel"><span class="ico gray cross"></span>Hủy</a>
				</div>
			</div>
		</form>
	</div>
</div>